import { UserProfilesAPI } from "../../request/api"
export default {
    namespaced: true,
    state: {
        // 购物车数量
        cartTotal: 10,
        userInfo: {
            // 鸡腿叔
            coin: 0,
            // 昵称
            nickName: "游客",
            // 头像
            headImg: require("../../assets/img/userImg.f8bbec5e.png")
        }
    },
    mutations: {
        chanUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal
            state.userInfo = payload.userInfo
        },
        initUserInfo(state) {
            state.cartTotal = 10;
            state.userInfo={
                // 鸡腿叔
                coin: 0,
                    // 昵称
                    nickName: "游客",
                        // 头像
                        headImg: require("../../assets/img/userImg.f8bbec5e.png")
            }
        }
    },
    actions: {
        async asyncChanUserInfo({ commit }) {
            let userInfoRes = await UserProfilesAPI();
            commit("chanUserInfo", userInfoRes.data)
        }
    },
}
